﻿Public Class DOCUMENTACAO

    Private Sub DOCUMENTACAO_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.DOCUMENTACAOTableAdapter.Fill(Me.DOCUMENTACAODataSet.DOCUMENTACAO)
    End Sub

    Private Sub PRIMEIRO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PRIMEIRO.Click
        DOCUMENTACAOBindingSource.MoveFirst()
    End Sub

    Private Sub VOLTAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VOLTAR.Click
        DOCUMENTACAOBindingSource.MovePrevious()
    End Sub

    Private Sub NOVO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NOVO.Click
        DOCUMENTACAOBindingSource.AddNew()
        CEDENTETextBox.Focus()
    End Sub

    Private Sub SALVAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SALVAR.Click
        Try
            Me.Validate()
            DOCUMENTACAOBindingSource.EndEdit()
            TableAdapterManager.UpdateAll(DOCUMENTACAODataSet)
        Catch EX As Exception
            MsgBox("ERRO NA ATUALIZAÇÃO DOS DADOS " & EX.ToString)
        End Try
    End Sub

    Private Sub DELETAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DELETAR.Click
        Try
            Me.Validate()
            DOCUMENTACAOBindingSource.RemoveCurrent()
            DOCUMENTACAOTableAdapter.Update(DOCUMENTACAODataSet.DOCUMENTACAO)
        Catch EX As Exception
            MsgBox("ERRO NA REMOÇÃO DOS DADOS " & EX.ToString)
        End Try
    End Sub

    Private Sub FRENTE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FRENTE.Click
        DOCUMENTACAOBindingSource.MoveNext()
    End Sub

    Private Sub ULTIMO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ULTIMO.Click
        DOCUMENTACAOBindingSource.MoveLast()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.DOCUMENTACAOTableAdapter.Fill(Me.DOCUMENTACAODataSet.DOCUMENTACAO)
    End Sub
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If CEDENTETextBox.Text = "" Then
            MsgBox("FAVOR INFORMAR NOME DO CEDENTE", MsgBoxStyle.Information)
        Else
            DOCUMENTACAOTableAdapter.FillByCEDENTE(DOCUMENTACAODataSet.DOCUMENTACAO, CEDENTETextBox.Text)
        End If
    End Sub

    Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        If SITUACAOComboBox.Text = "" Then
            MsgBox("FAVOR INFORMAR A SITUAÇÃO", MsgBoxStyle.Information)
        Else
            DOCUMENTACAOTableAdapter.FillBySITUACAO(DOCUMENTACAODataSet.DOCUMENTACAO, SITUACAOComboBox.Text)
        End If
    End Sub

    Private Sub DOCUMENTACAODataGridView_DataBindingComplete(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewBindingCompleteEventArgs) Handles DOCUMENTACAODataGridView.DataBindingComplete
        Try
            For intx As System.Int32 = 0 To DOCUMENTACAODataGridView.Rows.Count - 1
                Dim SITUACAO As System.String = DOCUMENTACAODataGridView.Rows(intx).Cells("DataGridViewTextBoxColumn44").Value.ToString
                If SITUACAO = "INATIVO" Then
                    DOCUMENTACAODataGridView.Rows(intx).DefaultCellStyle.BackColor = Color.Purple
                ElseIf SITUACAO = "EMPRESTIMO" Then
                    DOCUMENTACAODataGridView.Rows(intx).DefaultCellStyle.BackColor = Color.Violet
                End If
                Dim COROBS As System.String = DOCUMENTACAODataGridView.Rows(intx).Cells("DataGridViewTextBoxColumn61").Value.ToString
                If InStr(COROBS, "*") = 1 Then
                    DOCUMENTACAODataGridView.Rows(intx).DefaultCellStyle.BackColor = Color.Yellow
                End If
            Next
        Catch ex As Exception
            MsgBox("ERRO AO COLORIR AS LINHAS " & ex.ToString)
        End Try
    End Sub
End Class